﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Tube : MonoBehaviour {
    public float HoleY;
    public float HoleWIdth;

    public float MaxUpHigh;
    public float MaxUpLow;
    public float MaxDownHigh;
    public float MaxDownLow;

    public float MinHoleWidth;
    public float MaxHoleWidth;

    public bool InUse;

    public void RandBuild(float min, float max)
    {
        this.HoleWIdth = Random.Range(min, max);
        this.HoleY = Random.Range(Mathf.Min(this.MaxUpHigh - this.HoleWIdth / 2, this.MaxDownHigh + this.HoleWIdth / 2),
            Mathf.Max(this.MaxUpLow - this.HoleWIdth / 2, this.MaxDownLow + this.HoleWIdth / 2));
        Vector3 pos;
        pos = this.transform.Find("Up").transform.localPosition;
        pos.y = this.HoleY + this.HoleWIdth / 2;
        this.transform.Find("Up").transform.localPosition = pos;

        pos = this.transform.Find("Down").transform.localPosition;
        pos.y = this.HoleY - this.HoleWIdth / 2;
        this.transform.Find("Down").transform.localPosition = pos;
    }

    // Use this for initialization
    void Start () {
    }
	
	// Update is called once per frame
	void Update () {
		
	}
}
